package com.wookii.friedeggs

import android.app.Application
import android.util.Log
import androidx.room.Room
import com.baidu.ocr.sdk.OCR
import com.baidu.ocr.sdk.OnResultListener
import com.baidu.ocr.sdk.exception.OCRError
import com.baidu.ocr.sdk.model.AccessToken
import com.wookii.friedeggs.data.AppDatabase

/**
 *@Author Nick.wu
 *Date 2023/9/23
 */
class MyApplication: Application() {

    val database: AppDatabase by lazy {
        AppDatabase.getDatabase(this)
    }

    override fun onCreate() {
        super.onCreate()
        //初始化百度ocr，并且获取token
        OCR.getInstance(this).initAccessToken(object : OnResultListener<AccessToken> {
            override fun onResult(p0: AccessToken?) {
                Log.d("OCR", p0?.toString().toString())
            }

            override fun onError(p0: OCRError?) {
                Log.d("OCR", p0?.message.toString())
            }

        },applicationContext)
    }
}